
from redis import Redis
import redis
from app.config import ConfigObj
#pool = redis.ConnectionPool(host='10.255.21.210', password='xxx', port=6379, db=2)
#conn = redis.Redis(connection_pool=pool)

r: Redis = None

def init_redis_pool(conf: ConfigObj) -> Redis:
    print('>> init_redis_pool')
    pool = redis.ConnectionPool(host=conf.REDIS_HOST, password=conf.REDIS_PASS, 
                                port=conf.REDIS_PORT, db=conf.REDIS_DB)
    r = redis.Redis(connection_pool=pool)
    #redis = await create_redis_pool(f"redis://:yt123@10.255.21.210:6379/1?encoding=utf-8")
    return r

def get_redis() -> Redis:
    return r